/**
 * 
 */
package com.sad.controller;

import java.io.IOException;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sad.util.G;
import com.sad.util.PropertiesHolder;

/**
 * @author zhaoqy
 *
 */
public class InitListener implements ServletContextListener {

	private static final Logger logger = LoggerFactory.getLogger(InitListener.class);

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		logger.info("contextDestroyed");
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		logger.info("contextInitialized		begin:::");

		try {

			// Load core.properties
			PropertiesHolder.setProperties("/core.properties");

			G.system.systemName = PropertiesHolder.getPropertiesValue("/core.properties",
					"system.name", "物品租借管理控制台");

			G.system.url = PropertiesHolder.getPropertiesValue("/core.properties", "system.url",
					"http://182.92.171.210:8080");

			G.system.controller_package = PropertiesHolder.getPropertiesValue("/core.properties",
					"system.package.controller");

			G.system.service_package = PropertiesHolder.getPropertiesValue("/core.properties",
					"system.package.service");

			G.system.record_package = PropertiesHolder.getPropertiesValue("/core.properties",
					"system.package.record");

		} catch (IOException e) {
			logger.error(e.getMessage(), e);
		}

		logger.info("contextInitialized		:::end");
	}

}
